<template>
  <van-nav-bar title="登录" left-arrow @click="$router.back()">
    <template #right>
      <van-icon name="search" size="18" />
    </template>
  </van-nav-bar>
  <van-field
    v-model="user.tel"
    label="手机号"
    name="tel"
    placeholder="请输入手机号"
     
  
  />
  <van-field
    v-model="user.code"
    label="验证码"
    name="code"
    placeholder="请输入验证码"
  >
    <template #button>
      <van-count-down
        :time="time"
        class="left"
        format=" ss s"
        v-if="ispan"
        @finish="ispan = !ispan"
      />
      <van-button size="mini" round class="sent" v-else @click="dianji"
        >发送验证码</van-button
      >
    </template>
  </van-field>

  <div class="but">
    <van-button type="primary" block @click="onindex">登录</van-button>
  </div>
</template>
<script>
export default {
  components: {},
  name: "login",
  data() {
    return {
      user: {
        tel: "",
        code: "",
        show: false,
      },
       currentUser: {} ,// 当前登录用户信息
      time: 60 * 1000,
      ispan: false,
    };
  },
  methods: {
    dianji() {
      this.ispan = !this.ispan;
    },
	

    onindex() {
      if (this.user.tel == 1 && this.user.code == 1) {        
        this.$toast.success("登陆成功");
        this.$store.commit("setUser", this.user);
        this.$router.push("/mine");
      } else this.$toast.fail("登陆失败账户或密码错误");
    },
  },
};
</script>
<style lang="scss" scoped>
.but {
  padding: 26px 16px;
}
.left {
  padding-right: 16px;
}
.sent {
  width: 76px;
  height: 23px;
  background-color: #ededed;
  .van-button__text {
    font-size: 10px;
  }
}
</style>